Boost application performance
BOOST APPLICATION PERFORMANCE WITH AGE SENSITIVE DATA MANAGEMENT
Diginsight.SmartCache
introduces age sensitive data management: a new approach to managing data.
In highly distributed environments, data is inherently disconnected and often loaded across multiple boundaries.
For this reasons, loading data may be an expensive operation and loading data efficiently may become a critical challenge.
Not always fresh data data is strictly needed in our applications, to obtain the expected behaviour.
In many conditions, applications may work with data that is not up to date.
This is a great opportunity to boost applications performance: when fresh data is not strictly required data cached from previous calls or data pre-loaded in background may be used to ensure the shortest possible latencies.
WHAT IS AGE SENSITIVE DATA MANAGEMENT
With age sensitive data management, when loading data every entry is tagged with its Creation Date
.
Also, when accessing data, a developer can specify the maximum age that is required for it.
In Diginsight.SmartCache
this can be done by means of the following notation:
var options = new SmartCacheOperationOptions() { MaxAge = TimeSpan.FromSeconds(600) };
var userProfile = await userProfileService.FindUserByEmailAddressAsync(context.Account.Email, options).ConfigureAwait(false);
If the required age
for a data request is compatible with the creation date of the corresponding cache entry, data is returned from the cache (cache hit).
In case the required age
is not compatible with the creation date of the corresponding cache entry, the data is loaded from the remote location (cache miss) and the cache entry is updated.
In common caching systems
, the cache entries lifetime is defined at startup (or cache entry set time) and it cannot be changed across different calls.
A cache hit or a cache miss is determined by the static cache entry lifetime.
With Diginsight.SmartCache
the cache entry lifetime may be indefinite, and a cache hit or a cache miss is determined by the required age
, provided by the developer, at every single call, depending on the application need.
USE CASES
Diginsight.SmartCache
can be used with the following type of data: - data that is not frequently updated (eg. configuration data or static data) - data that is updated more frequently (eg. user profile or user permissions) - data that is updated very frequently (eg. notifications, messages or real time data)
Accessing configuration data or static data that is not frequently updated is a typical use case for all caching systems.
In this cases data doesn’t change and the developer can request data with a MaxAge of hours or days (eg. MaxAge = 00:04:00, 4 hours).
Data that is updated more frequently can be accessed with a shorter MaxAge (eg. MaxAge = 300, 5 minutes).
A typical example for this scenario can be access to a user profile or to user permissions.
By default, changes to the User Profile or the User Permissions will not be perceived by the application for a latency of 5 minutes.
In some circunstances the developer may need to be sure about the exact value of such data.
In these cases, the developer can just raise a request with MaxAge = 00:00.
It may happen that, notifications are available for changes to the cached user profile or the user permissions.
Upon such notifications, the developer may invalidate the cache entry or raise a request with MaxAge = 00:00 to load a cache entry for the same user, with the updated data.
When change notifications are handled properly, even if data changes frequently, the developer can use a longer MaxAge (eg. hours or days) and take maximum benefit from the cache, still without delays upon data changes.
Age sensitive data management becomes very useful when data changes very frequently.
As an example, consider an application showing notifications, messages or real time data.
When navigating across the pages speed of navigation may be a priority, so using cached data may be a good choice (still with a shorter MaxAge (eg. 120 secs)).
In these cases navigation will take benefit from the cache hits.
After the navigation completes, the developer may raise a request with MaxAge = 00:00 to load fresh data for the user.
In this way navigation will take advantage of cache hits speed and the user will still see fresh data, when the navigation ends.
AN OPPORTUNITY FOR PERFORMANCE: CACHE WITH PRELOADING
AN OPPORTUNITY FOR PERFORMANCE: MAXAGE PROMOTION
Sometimes, data from the past is immutable (eg. realtime data, user or devices messages).
In such cases, an automatic rule can be applied to promote MaxAge to a long or indefinite value (MaxAge promotion).
It may happen that a query or an API call loads data from the present together with data from the past.
When this happpens the request can be split automatically:
- Data from the present must be loaded with the MaxAge specified by the developer.
- Data from the past will take advantage of MaxAge promotion to a long or indefinite value.
Queries to the backend will be faster and with smaller payloads.
A OPPORTUNITY FOR PERFORMANCE: (AUTOMATIC) DATA PRELOADING
With age sensitive data management a new opportunity for performance is uncovered.
The required age
specified by the developer is of course used to determine if a cache hit or a cache miss can occur.
Such required age
can also be used as a time window, in the past, to preload data in background and ensure a cache hit will be obtained, when the application needs it.
Diginsight.SmartCache
captures this opportunity leveraging the application log to anticipate the required entries
, the required maxage
for them and anticipate entries preload in time for the application need.
SUMMARY
Diginsight.SmartCache
introduces age sensitive data management: a new approach to managing data:
When loading data a developer can specify the maximum age that is required for it.
A cache hit or a cache miss is determined by the required age
, provided at every single call and not by the cache entries lifetime that is defined at startup.
This allows using cache with non static data and data that is updated frequently without requiring delays in showing data changes, and always allowing easy access to fresh data whenever required.
Diginsight.SmartCache
allows MaxAge promotion and (automatic) data preloading techniques as great opportunities to boost application performance.
.